<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>10_自定义滚动条-滚轮事件基础-优化</title>
    </head>
    <body>
        <script>
            function move (event){

                var flag;

                if(event.wheelDelta){
                    if(event.wheelDelta > 0){
                        flag = true;
                    }else {
                        flag = false;
                    }

                }else if(event.detail){
                    if(event.detail < 0 ){
                        flag = true;
                    }else {
                        flag = false;
                    }
                }

                if(flag){
                    console.log('向上');
                }else{
                    console.log('向下');
                }

            }


            
            document.addEventListener('mousewheel',move);
            document.addEventListener('DOMMouseScroll',move);
        </script>
    </body>
</html>